package com.travelranking.pojo;

import java.io.Serializable;

import com.travelranking.rest.TravelWrapper;

public class Travel implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private City city;
	private String opinion;
	private Integer rank;
	private Long id;
	
	public Travel() {
		rank = 0;
		id = null;
		city = new City();
	}
	
	public Travel (TravelWrapper t){
		this.opinion = t.getOpinion();
		this.city = t.getCity();
		this.rank = t.getRank();
		this.id = t.getId();
	}
	
	public Long getId() {
		
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public void setRank(Integer rank) {
		this.rank = rank;
	}
	public Integer getRank() {
		return rank;
	}

	public City getCity() {
		return city;
	}

	public void setCity(City city) {
		this.city = city;
	}

	public String getOpinion() {
		return opinion;
	}
	public void setOpinion(String opinion) {
		this.opinion = opinion;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((city == null) ? 0 : city.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((opinion == null) ? 0 : opinion.hashCode());
		result = prime * result + ((rank == null) ? 0 : rank.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Travel other = (Travel) obj;
		if (city == null) {
			if (other.city != null)
				return false;
		} else if (!city.equals(other.city))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (opinion == null) {
			if (other.opinion != null)
				return false;
		} else if (!opinion.equals(other.opinion))
			return false;
		if (rank == null) {
			if (other.rank != null)
				return false;
		} else if (!rank.equals(other.rank))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Travel [city=" + city + ", opinion=" + opinion + ", rank="
				+ rank + ", id=" + id + "]";
	}
	
}
